package website.digitalocean.chapter4;

/**
 * @Author: 582895699@qq.com
 * @Desctription:
 * @Date: Created in 2023/2/9 22:05
 */
public class Computer {
    private String hdd;
    private String ram;
    private Boolean isGraphicsCardEnabled;
    private Boolean isBluetoothEnabled;

    public String getHdd() {
        return hdd;
    }

    public String getRam() {
        return ram;
    }

    public Boolean isGraphicsCardEnabled() {
        return isGraphicsCardEnabled;
    }

    public Boolean isBluetoothEnabled() {
        return isBluetoothEnabled;
    }

    public Computer(ComputerBuild build) {
        this.hdd = build.hdd;
        this.ram = build.ram;
        this.isGraphicsCardEnabled = build.isGraphicsCardEnabled;
        this.isBluetoothEnabled = build.isBluetoothEnabled;
    }

    @Override
    public String toString() {
        return "Computer{" +
                "hdd='" + hdd + '\'' +
                ", ram='" + ram + '\'' +
                ", isGraphicsCardEnabled=" + isGraphicsCardEnabled +
                ", isBluetoothEnabled=" + isBluetoothEnabled +
                '}';
    }

    public static class ComputerBuild {
        private String hdd;
        private String ram;
        private boolean isGraphicsCardEnabled;
        private boolean isBluetoothEnabled;

        public ComputerBuild(String hdd, String ram) {
            this.hdd = hdd;
            this.ram = ram;
        }

        public ComputerBuild setGraphicsCardEnabled(Boolean graphicsCardEnabled) {
            isGraphicsCardEnabled = graphicsCardEnabled;
            return this;
        }

        public ComputerBuild setBluetoothEnabled(Boolean bluetoothEnabled) {
            isBluetoothEnabled = bluetoothEnabled;
            return this;
        }

        public Computer build() {
            return new Computer(this);
        }
    }
}
